//#include "fileoption.h"
//#include <QFileDialog>
//#include <QMessageBox>

//fileoption::fileoption(MainWindow*parent)
//{   this->mainwindow = parent;
////    connect(actionOpen, &QAction::triggered, this, &fileoption::openFile); // modified
////    connect(actionSave, &QAction::triggered, this, &fileoption::saveFile); // added
//}
//void fileoption::SetUI()
//{
////    mainwindow->ui->PushButton->setText("开始");
//}
//void fileoption::openFile()
//{
//    QString fileName = QFileDialog::getOpenFileName(mainwindow);
//    if (!fileName.isEmpty())
//        readFromFile(fileName);
//}

//void fileoption::saveFile()
//{
//    QString fileName = QFileDialog::getSaveFileName(mainwindow);
//    if (!fileName.isEmpty())
//        writeToFile(fileName);
//}

//fileoption::~fileoption(){

//}
////读文件
//void fileoption::readFromFile(const QString &fileName)
//{
//    QFile file(fileName);

//    if (!file.open(QIODevice::ReadOnly)) {
//        QMessageBox::information(mainwindow, tr("Unable to open file"),
//            file.errorString());
//        return;
//    }

//   QVector<items> w;
//    QDataStream in(&file);
//    in >> w;

//    if (w.isEmpty()) {
//        QMessageBox::information(mainwindow, tr("No contacts in file"),
//                                 tr("The file you are attempting to open contains no contacts."));
//    } else {
//        for (int i = 0; i < w.size(); ++i)
//        mainwindow->addi(w[i].i_name, w[i].location, w[i].num);
//    }
//}
////写文件
//void fileoption::writeToFile(const QString &fileName)
//{
//    QFile file(fileName);

//    if (!file.open(QIODevice::WriteOnly)) {
//        QMessageBox::information(mainwindow, tr("Unable to open file"), file.errorString());
//        return;
//    }

//    QDataStream out(&file);
//    items*cur=mainwindow->gethead();
//    for (int i = 0;cur->next->isEmpty()!=1; ++i){
//        out << cur->getItem();
//        cur=cur->next;
//}
//}

